<%--
  Created by IntelliJ IDEA.
  User: xuzhongyao
  Date: 2017/6/6
  Time: 上午11:19
  To change this template use File | Settings | File Templates.
--%>
<%
    String path = request.getContextPath();
    String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort() + path + "/";
%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>公参导入</title>
    <meta http-equiv="X-UA-Compatible" content="IE=9; IE=EDGE">
    <meta http-equiv="X-UA-Compatible" content="IE=4">   <!-- IE5 mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=7.5"> <!-- IE7 mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=100"> <!-- IE8 mode -->
    <meta http-equiv="X-UA-Compatible" content="IE=a">   <!-- IE5 mode -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <link href="<%=path%>/static/hplus/css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="<%=path%>/static/hplus/css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <!-- jqgrid-->
    <link href="<%=path%>/static/hplus/css/plugins/jqgrid/ui.jqgrid.css?0820" rel="stylesheet">

    <link href="<%=path%>/static/hplus/css/animate.css" rel="stylesheet">
    <link href="<%=path%>/static/hplus/css/style.css?v=4.1.0" rel="stylesheet">
    <link href="<%=path%>/static/hplus/css/plugins/toastr/toastr.min.css" rel="stylesheet">
    <link href="<%=path%>/static/hplus/css/plugins/dropzone/basic.css" rel="stylesheet">
    <link href="<%=path%>/static/hplus/css/plugins/dropzone/dropzone.css" rel="stylesheet">
    <style>
        html,body{
            background-color: #eeeeee;
        }
        p{
            margin-bottom: 0px;
        }
    </style>
</head>
<body>
<!-- Stack the columns on mobile by making one full-width and the other half-width -->
<div class="row" style="padding: 20px;">
    <div class="col-xs-12">
        <!-- Standard button -->
        <button type="button" class="btn btn-info" id="imp">导入公参</button>
        <!-- Provides extra visual weight and identifies the primary action in a set of buttons -->
        <a type="button" class="btn btn-primary" href="<%=path%>/static/hplus/template.xlsx">下载导入模板</a>
    </div>
    <div class="col-sm-12" style="margin-top: 10px;#font-size: 12px;">
        <div class="ibox">
            <div class="jqGrid_wrapper" style="background-color: white;">
                <table id="table_list_1" style="overflow-x: scroll;"></table>
                <div id="pager_list_1"></div>
            </div>
        </div>
    </div>
    <form id="mmmm334" action="<%=path%>/uploadExcel" method="post">
        <input id="file" type="file" name="file" style="display: none;">
    </form>

</div>
<!-- 全局js -->
<script src="<%=path%>/static/hplus/js/jquery.min.js?v=2.1.4"></script>
<script src="<%=path%>/static/hplus/js/bootstrap.min.js?v=3.3.6"></script>
<!-- Peity -->
<script src="<%=path%>/static/hplus/js/plugins/peity/jquery.peity.min.js"></script>
<!-- jqGrid -->
<script src="<%=path%>/static/hplus/js/plugins/jqgrid/i18n/grid.locale-cn.js"></script>
<script src="<%=path%>/static/hplus/js/plugins/jqgrid/jquery.jqGrid.min.js"></script>
<!-- Input Mask-->
<script src="<%=path%>/static/hplus/js/plugins/jasny/jasny-bootstrap.min.js"></script>
<!-- jQuery Validation plugin javascript-->
<script src="<%=path%>/static/hplus/js/plugins/validate/jquery.validate.min.js"></script>
<script src="<%=path%>/static/hplus/js/plugins/validate/messages_zh.min.js"></script>
<script src="<%=path%>/static/hplus/js/demo/form-validate-demo.js"></script>
<!-- Toastr script -->
<script src="<%=path%>/static/hplus/js/plugins/toastr/toastr.min.js"></script>
<script src="<%=path%>/static/hplus/js/plugins/layer/laydate/laydate.js"></script>
<script>
    $(function () {
        var $btn = $('#imp');
        $('#imp').click(function () {
            $('input[name="file"]').click();
        });

        $('input[name="file"]').change(function () {
            $btn.attr("disabled", true);
            $btn.text("导入中...")
            var formData = new FormData($("#mmmm334")[0]);
            $.ajax({
                url: '<%=path%>/uploadExcel',
                type: 'POST',
                data: formData,
                cache: false,
                contentType: false,
                processData: false,
                success: function (data) {
                    console.log(data);
                    if (data) {
                        alert('导入成功');
                        $("#table_list_1").jqGrid().trigger('reloadGrid');
                    } else {
                        alert('导入失败')
                    }
                    $("#mmmm334")[0].reset();
                    $btn.attr("disabled", false);
                    $btn.text("导入公参");
                },
                error: function (error) {
                    alert('请求超时')
                    $("#mmmm334")[0].reset();
                    $btn.attr("disabled", false);
                    $btn.text("导入公参");
                }
            });

        });

        $.jgrid.defaults.styleUI = 'Bootstrap';
        $("#table_list_1").jqGrid({
            url: "<%=path%>/selectPubPar",
            datatype: "json",
            height: 'auto',
            autowidth: true,
            rowNum: 15,
            rowList: [15, 20, 30],
            colNames: ["<p style='text-align: center;'>AreaName</p>",
                "<p style='text-align: center;'>CellName</p>",
                "<p style='text-align: center;'>eNodeBID</p>",
                "<p style='text-align: center;'>CELLID</p>",
                "<p style='text-align: center;'>Latitude</p>",
                "<p style='text-align: center;'>Longitude</p>",
                "<p style='text-align: center;'>Azimuth</p>"],
            colModel: [
                {
                    name: 'areaName',
                    index: 'areaName',
                    align: 'center',
                    width: 60
                }, {
                    name: 'cellName',
                    index: 'cellName',
                    align: 'center',
                    width: 100
                }, {
                    name: 'enodeBID',
                    index: 'eNodeBID',
                    align: 'center',
                    width: 60
                }, {
                    name: 'cellID',
                    index: 'cellID',
                    align: 'center',
                    width: 60
                }, {
                    name: 'latitude',
                    index: 'latitude',
                    align: 'center',
                    width: 60
                }, {
                    name: 'longitude',
                    index: 'longitude',
                    align: 'center',
                    width: 60
                }, {
                    name: 'azimuth',
                    index: 'azimuth',
                    align: 'center',
                    width: 60
                }
            ],
            pager: "#pager_list_1",
            viewrecords: true,
            shrinkToFit: true,
            hidegrid: false,
            //multiselect: true,//复选框
            page: 1,
            onSelectRow: function (rowid) {

            },
            gridComplete: function () {


            }

        });
        $(window).bind('resize', function () {
            var width = $('.jqGrid_wrapper').width();
            $('#table_list_1').setGridWidth(width);
        });
    })
</script>
</body>
</html>
